package com.wanxi.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/a")
public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        System.out.println("aaa");
//        TestServlet testServlet = new TestServlet();
        Student[] students = new Student[4];
        students[0] = new Student(1, "aa1", 121);
        students[1] = new Student(2, "aa2", 122);
        students[2] = new Student(3, "aa3", 123);
        students[3] = new Student(4, "aa4", 124);
        req.setAttribute("students", students);
        req.getRequestDispatcher("index.jsp").forward(req, resp);
    }
}
